import type { VbenFormSchema } from '#/adapter/form';
import { z } from '#/adapter/form';
import { ref } from 'vue';

export const idKey = ref('storeId');

// 编辑弹窗表单配置
export const formSchema: VbenFormSchema[] = [
  {
    component: 'Input',
    defaultValue: '',
    fieldName: idKey.value,
    label: '微馆id',
    dependencies: {
      show() {
        return false;
      },
      triggerFields: [''],
    },
  },
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入微馆名称',
      maxLength: 12,
      allowClear: true,
    },
    fieldName: 'storeName',
    label: '微馆名称',
    rules: 'required',
  },
  {
    component: 'ImageUpload',
    fieldName: 'storeLogo',
    help: 'LOGO建议尺寸400*400',
    label: '微馆LOGO',
    rules: z.string().min(1, { message: '请上传LOGO，建议尺寸400*400' }),
  },
  {
    component: 'ImageUpload',
    fieldName: 'shareImg',
    help: '小程序分享封面，建议比例5：4',
    label: '小程序分享封面',
    rules: z.string().min(1, { message: '小程序分享封面，建议比例5：4' }),
  },
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入微馆所在小区名',
      allowClear: true,
    },
    fieldName: 'position',
    label: '小区名',
    rules: 'required',
  },
  {
    component: 'Input',
    fieldName: 'coordinate',
    label: '小区位置',
    rules: z.string().min(1, { message: '请选择小区定位位置' }),
  },
  {
    component: 'Input',
    fieldName: 'lat',
    label: '小区定位',
    dependencies: {
      show() {
        return false;
      },
      triggerFields: [''],
    },
  },
  {
    component: 'Input',
    fieldName: 'lng',
    label: '小区定位',
    dependencies: {
      show() {
        return false;
      },
      triggerFields: [''],
    },
  },
  {
    component: 'Textarea',
    componentProps: {
      placeholder: '请输入微馆详细地址',
      allowClear: true,
    },
    fieldName: 'address',
    label: '详细地址',
    rules: 'required',
  },
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入微馆联系人',
      allowClear: true,
    },
    fieldName: 'director',
    label: '微馆联系人',
    rules: 'required',
  },
  {
    component: 'Input',
    componentProps: {
      placeholder: '请输入微馆联系方式',
      allowClear: true,
    },
    fieldName: 'tel',
    label: '联系方式',
    rules: 'required',
  },
  {
    component: 'TinymceEditor',
    fieldName: 'introduction',
    label: '微馆简介',
    rules: 'required',
  },
];
